/*
===============================================================================
Chili is the jQuery code highlighter plugin
...............................................................................
LICENSE: http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/chili/

                                               Copyright 2008 / Andrea Ercolino
===============================================================================
*/

{
	  _name: 'cfml'
	, _case: false
	, _main: {
		  doctype: { 
			  _match: /<!DOCTYPE\b[\w\W]*?>/ 
			, _style: "color: #CC6600;"
		}
		, ie_style: {
			  _match: /(<!--\[[^\]]*\]>)([\w\W]*?)(<!\[[^\]]*\]-->)/
			, _replace: function( all, open, content, close ) {
				return "<span class='ie_style'>" + this.x( open ) + "</span>" 
					  + this.x( content, '//style' ) 
					  + "<span class='ie_style'>" + this.x( close ) + "</span>";
			}
			, _style: "color: DarkSlateGray;"
		}
		, cf_comment: { 
			  _match: /<!---[\w\W]*?--->/ 
			, _style: "color: #808080;"
		}
		, comment: { 
			  _match: /<!--[\w\W]*?-->/ 
			, _style: "color: #609960;"
		}
		, script: { 
			  _match: /(<script\s+[^>]*>)([\w\W]*?)(<\/script\s*>)/
			, _replace: function( all, open, content, close ) { 
				  return this.x( open, '//tag_start' ) 
					  + this.x( content, 'js' ) 
					  + this.x( close, '//tag_end' );
			}
		}
		, style: { 
			  _match: /(<style\s+[^>]*>)([\w\W]*?)(<\/style\s*>)/
			, _replace: function( all, open, content, close ) { 
				  return this.x( open, '//tag_start' ) 
					  + this.x( content, 'css' ) 
					  + this.x( close, '//tag_end' );
			} 
		}
		// matches a lib: custom tag (with attrs)
		// like "<lib:tag ... >"
		, lib_tag_start: { 
			  _match: /(<\w+:\w+)((?:[?%]>|[\w\W])*?)(\/>|>)/ 
			, _replace: function( all, open, content, close ) { 
				  return "<span class='lib_tag_start'>" + this.x( open ) + "</span>" 
					  + this.x( content, '/lib_tag_attrs' ) 
					  + "<span class='lib_tag_start'>" + this.x( close ) + "</span>";
			}
			, _style: "color: #3c3caa;"
		} 
		// matches a lib:custom ending tag
		// like "</lib:tag>"
		, lib_tag_end: { 
			  _match: /<\/\w+:\w+\s*>|\/>/ 
			, _style: "color: #3c3caa;"
		}
		// matches a cf starting tag (with attrs)
		// like "<cfoutput ... >" or "<cfabort ... />"
		, cf_tag_start: { 
			  _match: /(<cf\w+)((?:[?%]>|[\w\W])*?)(\/>|>)/ 
			, _replace: function( all, open, content, close ) { 
				  return "<span class='cf_tag_start'>" + this.x( open ) + "</span>" 
					  + this.x( content, '/cf_tag_attrs' ) 
					  + "<span class='cf_tag_start'>" + this.x( close ) + "</span>";
			}
			, _style: "color: #800000;"
		} 
		// matches a cf ending tag
		// like "</cfoutput>"
		, cf_tag_end: { 
			  _match: /<\/cf\w+\s*>|\/>/ 
			, _style: "color: #800000;"
		}
		// matches a starting tag of an element (with attrs)
		// like "<div ... >" or "<img ... />"
		, form_tag_start: { 
			  _match: /(<(?:form|input|label|textarea|button|select|option|optgroup|fieldset|legend))((?:[?%]>|[\w\W])*?)(\/>|>)/ 
			, _replace: function( all, open, content, close ) { 
				  return "<span class='form_tag_start'>" + this.x( open ) + "</span>" 
					  + this.x( content, '/form_tag_attrs' ) 
					  + "<span class='form_tag_start'>" + this.x( close ) + "</span>";
			}
			, _style: "color: #c38800;"
		} 
		// matches an ending tag
		// like "</div>"
		, form_tag_end: { 
			  _match: /<\/(?:form|input|label|textarea|button|select|option|optgroup|fieldset|legend)\s*(>|\/>)/ 
			, _style: "color: #c38800;"
		}
		// matches a starting tag of an element (with attrs)
		// like "<div ... >" or "<img ... />"
		, tag_start: { 
			  _match: /(<\w+)((?:[?%]>|[\w\W])*?)(\/>|>)/ 
			, _replace: function( all, open, content, close ) { 
				  return "<span class='tag_start'>" + this.x( open ) + "</span>" 
					  + this.x( content, '/tag_attrs' ) 
					  + "<span class='tag_start'>" + this.x( close ) + "</span>";
			}
			, _style: "color: #000080;"
		} 
		// matches an ending tag
		// like "</div>"
		, tag_end: { 
			  _match: /<\/\w+\s*>|\/>/ 
			, _style: "color: #000080;"
		}
		, entity: { 
			  _match: /&\w+?;/ 
			, _style: "color: blue;"
		}
	}
	, cf_tag_attrs: {
		// matches a name/value pair
		attr: {
			// before in $1, name in $2, between in $3, value in $4
			  _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ 
			, _replace: "$1<span class='cf_attr_name'>$2$3</span><span class='cf_attr_value'>$4</span>"
			, _style: { cf_attr_name:  "color: #800000;", cf_attr_value: "color: blue;" }
		}
	}
	, lib_tag_attrs: {
		// matches a name/value pair
		attr: {
			// before in $1, name in $2, between in $3, value in $4
			  _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ 
			, _replace: "$1<span class='lib_attr_name'>$2$3</span><span class='lib_attr_value'>$4</span>"
			, _style: { lib_attr_name:  "color: #3c3caa;", lib_attr_value: "color: blue;" }
		}
		, 
		attr2: {
			// before in $1, name in $2
			  _match: /(\W*?)([\w-]+)/ 
			, _replace: "$1<span class='lib_attr_single'>$2</span>"
			, _style: { lib_attr_single:  "color: #3c3caa;" }
		}
	}
	, form_tag_attrs: {
		// matches a name/value pair
		attr: {
			// before in $1, name in $2, between in $3, value in $4
			  _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ 
			, _replace: "$1<span class='form_attr_name'>$2$3</span><span class='attr_value'>$4</span>"
			, _style: { form_attr_name:  "color: #c38800;", attr_value: "color: blue;" }
		}
		, 
		attr2: {
			// before in $1, name in $2
			  _match: /(\W*?)([\w-]+)/ 
			, _replace: "$1<span class='form_attr_single'>$2</span>"
			, _style: { form_attr_single:  "color: #c38800;" }
		}
	}
	, tag_attrs: {
		// matches a name/value pair
		attr: {
			// before in $1, name in $2, between in $3, value in $4
			  _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ 
			, _replace: "$1<span class='attr_name'>$2$3</span><span class='attr_value'>$4</span>"
			, _style: { attr_name:  "color: #000080;", attr_value: "color: blue;" }
		}
	}
}
